package org.linlinjava.litemall.wx.controller;

import org.linlinjava.litemall.core.notify.netty.PushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 把控制器
 *
 * @author yliyun
 * @description：TODO
 * @date 2022/09/14
 */
@RestController
@RequestMapping("/wx/push")
public class PushController {
    /**
     * 推动服务
     */
    @Autowired
    private PushService pushService;

    /**
     * 推送给所有用户
     *
     * @param msg 消息
     */
    @PostMapping("/pushAll")
    public void pushToAll(@RequestParam("msg") String msg){
        pushService.pushMsgToAll(msg);
    }

    /**
     * 推送给指定用户
     *
     * @param userId 用户id
     * @param msg    消息
     */
    @PostMapping("/pushOne")
    public void pushMsgToOne(@RequestParam("userId") String userId,@RequestParam("msg") String msg){
        pushService.pushMsgToOne(userId,msg);
    }


    /**
     * 推送给指定门店
     *
     * @param shopId 商店id
     * @param msg    消息
     */
    @PostMapping("/pushShop")
    public void pushMsgToShop(@RequestParam("shopId") Integer shopId,@RequestParam("msg") String msg){
        pushService.pushMsgToShop(msg,shopId);
    }
}
